<?php
	require_once "../php/include/global.php";	
?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="js/jquery-1.4.4.min.js"></script>
	<script src="../js/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../js/jquery-ui-1.8.16.custom.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/jquery.maskedinput-1.2.2.min.js"></script>
	<link type="text/css" href="../css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
	<style type="text/css">
			/*demo page css*/
			body{ font: 62.5% "Trebuchet MS", sans-serif; }
			.demoHeaders { margin-top: 2em; }
			#dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
			#dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
			ul#icons {margin: 0; padding: 0;}
			ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
			ul#icons span.ui-icon {float: left; margin: 0 4px;}
		</style>
	<script type="text/javascript" language="javascript">
	$(function($){
		var dates = $( "#from, #to" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 3,
			dateFormat: "yy-mm-dd",
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
		setInterval(function(){
			$.post('../php/include/global.php', {variable:'stat_in_processing'},//передали
			function(data)
			{
				if (data=='true')
				{
					$( "#progressbar" ).show();
					$.post('../php/include/global.php', {variable:'stat_in_converter'},//передали
					function(data)
					{
						var val = parseInt(data);
						$( "#progressbar" ).progressbar({
							value: val
						});
					});
				}
				else
				{
					$( "#progressbar" ).hide();
				}
			});
		}, 100);
		$('#form_queue').submit(function(){
			var tosend = $(this).serialize();
			$.post('test_s.php', tosend, function(data) {
				$('#result').html(data);
				$('#to_firm').show();
				window.location.reload();
			})
			return false;
		})
		
		$('#chk_minup').live('click',function(){
			$('#plain').toggle();
			$('#minup').toggle();
		})
		btn_setperiod('monthbegin','date');
	})
	
	btn_setperiod = function(from_,to_){
		$('[name="db[queue_from]"]').val(getDatetime(from_));
		$('[name="db[queue_to]"]').val(getDatetime(to_));
	}
	getDatetime = function(k_){//k_ = [''|'date'|'time'] 
		//получение даты (сегодняшний день) вида DATETIME MySQL 
		//без ключа yyyy-mm-dd hh:mm:ss
		//ключ date только yyyy-mm-dd
		//ключ time только hh:mm:s
		var add0 = function(val_){val_+='';val_.length==1?val_='0'+val_:val_;return val_;}
		var date = new Date();
		var day = add0(date.getDate());
		var month = add0((date.getMonth()+1));
		var year = add0(date.getFullYear());
		var hour = add0(date.getHours());
		var min  = add0(date.getMinutes());
		var sec  = add0(date.getSeconds());
		
		switch(k_){
			case 'date':
				return year+'-'+month+'-'+day;	
			case 'time':
				return hour+':'+min+':'+sec;
			case 'ms':
				return hour+':'+min+':'+sec + '.' + date.getMilliseconds();
			case 'daybegin':
				return year+'-'+month+'-'+day+' 00:00:00';
			case 'dayend':
				return year+'-'+month+'-'+day+' 23:59:59';
			case 'monthbegin':
				return year+'-'+month+'-01';
			default : return year+'-'+month+'-'+day+' '+hour+':'+min+':'+sec;
				
		}
	}
	</script>

</head>
<body >
	
</body>
</html>